package com.tanhua.server.job;

import com.tanhua.server.interceptor.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Set;


@Component
@Slf4j
public class DeleteRedis {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @Scheduled(cron = " 0 0 0 * * ?")
    public void deleteRedis(){

        String receiveVoiceKey="Uservoice_";

        Set<String> keys = redisTemplate.keys(receiveVoiceKey + "*");
        System.out.println(keys+"...");

        for (String key : keys) {
            redisTemplate.delete(key);
        }
        // 每天的凌晨十二点:删除redis中存储的发送语音次数
        System.out.println("开始删除");
    }
}
